﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Planisoft.Entities;
using System.Data.SqlClient;

namespace Planisoft.DAO
{
    public class ValorRegPensionarioDAO : MasterDataAcces , IValorRegPensionarioDAO
    {

        public void AddValorRegPensionario(int id, int fondoAfp, int comisionAfp, int primaAfp, string AnioAfp, string MesAfp)
        {
            var parmId = new SqlParameter("@id", id);
            var parmFondoAfp = new SqlParameter("@fondoAfp", fondoAfp);
            var parmComisionAfp = new SqlParameter("@comisionAfp", comisionAfp);
            var parmPrimaAfp = new SqlParameter("@primaAfp", primaAfp);
            var parmAnioAfp = new SqlParameter("@AnioAfp", AnioAfp);
            var parmMesAfp = new SqlParameter("@MesAfp", MesAfp);

            /*object[] param = new object[6];
            param[0] = parmId;
            param[1] = parmFondoAfp;
            param[2] = parmComisionAfp;
            param[3] = parmPrimaAfp;
            param[4] = parmAnioAfp;
            param[5] = parmMesAfp;*/

            //var query = Context.Database.ExecuteSqlCommand("InsertPlanillaByTrabajador @id", parmCodTrabajador);

            var query = Context.Database.ExecuteSqlCommand("AddValorRegPensionario @id,@fondoAfp,@comisionAfp,@primaAfp,@AnioAfp,@MesAfp", parmId, parmFondoAfp, parmComisionAfp, parmPrimaAfp, parmAnioAfp, parmMesAfp);

            //turn query.ToList();

        }


        public List<ValoresRegPensionario> GetAllFromRegPensionarioByPeriodo(int id)
        {
            var query = from rpp in Context.ValoresRegPensionarios
                            orderby rpp.IdRegPensionario
                            select rpp;
            return query.ToList();
        }
    }
}
